This is a summary of the primary figures and tests I have completed for Chapter 2 as of my oral exams (April 2018), as well as accompanying notes and questions.
predictors <- site.sum %>% select(cover_LC,cover_TA,canopy_MA,canopy_TA,rugosity,scar.BM,scar.DEN,carn.BM) # should it matter if I use site level summary data vs. full follow dataset (where site-level data has been joined?)
pca <- prcomp(na.omit(predictors),center = TRUE,scale. = TRUE)
summary(pca)
## Importance of components:
## PC1 PC2 PC3 PC4 PC5 PC6
## Standard deviation 2.1310 1.4982 0.79477 0.47902 0.45634 0.30914
## Proportion of Variance 0.5677 0.2806 0.07896 0.02868 0.02603 0.01195
## Cumulative Proportion 0.5677 0.8482 0.92719 0.95587 0.98190 0.99385
## PC7 PC8
## Standard deviation 0.21046 0.07020
## Proportion of Variance 0.00554 0.00062
## Cumulative Proportion 0.99938 1.00000
plot(pca,type="l")
ggbiplot(pca, obs.scale = 1, var.scale = 1, groups=site.sum$Island, ellipse = TRUE, circle = TRUE, varname.size = 2) + scale_color_manual(name="Island", values=c("navy", "darkseagreen", "slategray2")) + theme(legend.direction = 'horizontal', legend.position = 'top') + theme_minimal()
## Df Sum Sq Mean Sq F value Pr(>F)
## Island 2 19315250 9657625 24.65 2.57e-09 ***
## Residuals 93 36432745 391750
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = FR ~ Island, data = vet20init)
##
## $Island
## diff lwr upr p adj
## Barbuda-Antigua -42.79233 -540.4860 454.9014 0.9771505
## Bonaire-Antigua 903.54977 493.9521 1313.1474 0.0000028
## Bonaire-Barbuda 946.34211 553.9021 1338.7821 0.0000003
## Levene's Test for Homogeneity of Variance (center = median)
## Df F value Pr(>F)
## group 2 0.117 0.8897
## 93
## Df Sum Sq Mean Sq F value Pr(>F)
## Island 2 3765399 1882699 25.35 5.73e-10 ***
## Residuals 125 9283349 74267
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = FR ~ Island, data = vir20init, white.adjust = TRUE)
##
## $Island
## diff lwr upr p adj
## Barbuda-Antigua 315.65455 164.6361 466.6730 0.0000068
## Bonaire-Antigua 364.50714 234.9929 494.0214 0.0000000
## Bonaire-Barbuda 48.85258 -105.4620 203.1672 0.7336418
## Levene's Test for Homogeneity of Variance (center = median)
## Df F value Pr(>F)
## group 2 2.2444 0.1102
## 125
## Df Sum Sq Mean Sq F value Pr(>F)
## Island 2 0.519 0.2594 2.501 0.0875 .
## Residuals 93 9.646 0.1037
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = BR ~ Island, data = vet20init, white.adjust = TRUE)
##
## $Island
## diff lwr upr p adj
## Barbuda-Antigua 0.08541907 -0.17066607 0.3415042 0.7073489
## Bonaire-Antigua 0.18703474 -0.02372113 0.3977906 0.0925502
## Bonaire-Barbuda 0.10161566 -0.10031186 0.3035432 0.4570074
## Levene's Test for Homogeneity of Variance (center = median)
## Df F value Pr(>F)
## group 2 9.2302 0.0002205 ***
## 93
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Df Sum Sq Mean Sq F value Pr(>F)
## Island 2 0.018 0.00881 0.176 0.839
## Residuals 125 6.248 0.04998
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = BR ~ Island, data = vet20init, white.adjust = TRUE)
##
## $Island
## diff lwr upr p adj
## Barbuda-Antigua 0.08541907 -0.17066607 0.3415042 0.7073489
## Bonaire-Antigua 0.18703474 -0.02372113 0.3977906 0.0925502
## Bonaire-Barbuda 0.10161566 -0.10031186 0.3035432 0.4570074
## Levene's Test for Homogeneity of Variance (center = median)
## Df F value Pr(>F)
## group 2 10.278 7.37e-05 ***
## 125
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Df Sum Sq Mean Sq F value Pr(>F)
## Island 2 0.519 0.2594 2.501 0.0875 .
## Residuals 93 9.646 0.1037
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Levene's Test for Homogeneity of Variance (center = median)
## Df F value Pr(>F)
## group 2 9.2302 0.0002205 ***
## 93
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Df Sum Sq Mean Sq F value Pr(>F)
## Island 2 0.018 0.00881 0.176 0.839
## Residuals 125 6.248 0.04998
## Levene's Test for Homogeneity of Variance (center = median)
## Df F value Pr(>F)
## group 2 10.278 7.37e-05 ***
## 125
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Df Sum Sq Mean Sq F value Pr(>F)
## Island 2 1454 727.2 8.178 0.000553 ***
## Residuals 88 7826 88.9
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 5 observations deleted due to missingness
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = for.bites ~ Island, data = vet20init, white.adjust = TRUE)
##
## $Island
## diff lwr upr p adj
## Barbuda-Antigua 0.6045833 -7.475190 8.684356 0.9826131
## Bonaire-Antigua 8.7394246 2.249595 15.229255 0.0052116
## Bonaire-Barbuda 8.1348413 1.809338 14.460345 0.0080319
## Levene's Test for Homogeneity of Variance (center = median)
## Df F value Pr(>F)
## group 2 1.9666 0.146
## 88
## Df Sum Sq Mean Sq F value Pr(>F)
## Island 2 813 406.7 12.46 1.26e-05 ***
## Residuals 115 3753 32.6
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 10 observations deleted due to missingness
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = for.bites ~ Island, data = vir20init, white.adjust = TRUE)
##
## $Island
## diff lwr upr p adj
## Barbuda-Antigua 3.431446 0.1293407 6.733552 0.0397136
## Bonaire-Antigua 5.966846 3.1227232 8.810969 0.0000067
## Bonaire-Barbuda 2.535400 -0.7532184 5.824018 0.1642219
## Levene's Test for Homogeneity of Variance (center = median)
## Df F value Pr(>F)
## group 2 5.3717 0.005885 **
## 115
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Due to the lack of larger fish in Barbuda, these length-based relationships focus on comparisons between Antigua and Bonaire
vetinit <- data %>% filter(Species.Code=="qup" & Phase=="i")
gamm<-gamm(FR~s(Length.cm)+s(scar.BM)+s(PC1)+s(PC2), family=gaussian(link=identity),data=vetinit, random=list(Island=~1),method="REML")
summary(gamm$gam) # only PC1 and PC2 are significant, length slightly, scar.BM is not
##
## Family: gaussian
## Link function: identity
##
## Formula:
## FR ~ s(Length.cm) + s(scar.BM) + s(PC1) + s(PC2)
##
## Parametric coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1242.07 41.11 30.21 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Approximate significance of smooth terms:
## edf Ref.df F p-value
## s(Length.cm) 4.437 4.437 3.206 0.0297 *
## s(scar.BM) 1.402 1.402 0.834 0.2519
## s(PC1) 1.000 1.000 30.719 1.06e-07 ***
## s(PC2) 3.821 3.821 7.012 3.74e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## R-sq.(adj) = 0.443
## Scale est. = 3.0251e+05 n = 179
AIC(gamm$lme)
## [1] 2753.156
plot(gamm$gam,pages=1)
gamm<-gamm(g.frac~s(Length.cm)+s(scar.BM)+s(PC1)+s(PC2), family=gaussian(link=identity),data=vetinit, random=list(Island=~1),method="REML")
summary(gamm$gam) # PC1 and PC2 are most significant, length is significant, scar.BM is almost significant
##
## Family: gaussian
## Link function: identity
##
## Formula:
## g.frac ~ s(Length.cm) + s(scar.BM) + s(PC1) + s(PC2)
##
## Parametric coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.40498 0.01236 32.78 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Approximate significance of smooth terms:
## edf Ref.df F p-value
## s(Length.cm) 5.198 5.198 5.199 0.000135 ***
## s(scar.BM) 1.452 1.452 2.121 0.074590 .
## s(PC1) 1.000 1.000 34.635 1.91e-08 ***
## s(PC2) 4.283 4.283 10.104 9.79e-08 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## R-sq.(adj) = 0.487
## Scale est. = 0.027324 n = 179
plot(gamm$gam,pages=1)
gamm<-gamm(for.bites~s(Length.cm)+s(scar.BM)+s(PC1)+s(PC2), family=gaussian(link=identity),data=vetinit, random=list(Island=~1),method="REML")
summary(gamm$gam) # very low R2, only PC1 and scar.BM significant
##
## Family: gaussian
## Link function: identity
##
## Formula:
## for.bites ~ s(Length.cm) + s(scar.BM) + s(PC1) + s(PC2)
##
## Parametric coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 12.2414 0.6197 19.75 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Approximate significance of smooth terms:
## edf Ref.df F p-value
## s(Length.cm) 1 1 0.051 0.8211
## s(scar.BM) 1 1 4.089 0.0448 *
## s(PC1) 1 1 5.932 0.0159 *
## s(PC2) 1 1 0.483 0.4880
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## R-sq.(adj) = 0.179
## Scale est. = 64.525 n = 168
plot(gamm$gam,pages=1)
virinit <- data %>% filter(Species.Code=="stop" & Phase=="i")
gamm<-gamm(FR~s(Length.cm)+s(scar.BM)+s(PC1)+s(PC2), family=gaussian(link=identity),data=virinit, random=list(Island=~1),method="REML")
summary(gamm$gam) #PC1, length, and scar.BM are significant predictors
##
## Family: gaussian
## Link function: identity
##
## Formula:
## FR ~ s(Length.cm) + s(scar.BM) + s(PC1) + s(PC2)
##
## Parametric coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 466.37 17.92 26.03 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Approximate significance of smooth terms:
## edf Ref.df F p-value
## s(Length.cm) 1.00 1.00 15.856 9.35e-05 ***
## s(scar.BM) 1.00 1.00 4.696 0.0313 *
## s(PC1) 3.12 3.12 17.807 1.22e-10 ***
## s(PC2) 1.00 1.00 1.796 0.1816
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## R-sq.(adj) = 0.332
## Scale est. = 69343 n = 216
plot(gamm$gam,pages=1)
gamm<-gamm(g.frac~s(Length.cm)+s(scar.BM)+s(PC1)+s(PC2), family=gaussian(link=identity),data=virinit, random=list(Island=~1),method="REML")
summary(gamm$gam) #PC1, length, and scar.BM are significant predictors
##
## Family: gaussian
## Link function: identity
##
## Formula:
## g.frac ~ s(Length.cm) + s(scar.BM) + s(PC1) + s(PC2)
##
## Parametric coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.38137 0.01606 23.75 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Approximate significance of smooth terms:
## edf Ref.df F p-value
## s(Length.cm) 1.000 1.000 8.185 0.00464 **
## s(scar.BM) 1.000 1.000 5.765 0.01720 *
## s(PC1) 3.216 3.216 18.017 6.86e-11 ***
## s(PC2) 1.000 1.000 1.581 0.21004
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## R-sq.(adj) = 0.32
## Scale est. = 0.05571 n = 216
plot(gamm$gam,pages=1)
gamm<-gamm(for.bites~s(Length.cm)+s(scar.BM)+s(PC1)+s(PC2), family=gaussian(link=identity),data=virinit, random=list(Island=~1),method="REML")
summary(gamm$gam) # no significant predictors (scar.BM almost), low r2
##
## Family: gaussian
## Link function: identity
##
## Formula:
## for.bites ~ s(Length.cm) + s(scar.BM) + s(PC1) + s(PC2)
##
## Parametric coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 6.981 1.381 5.057 1.01e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Approximate significance of smooth terms:
## edf Ref.df F p-value
## s(Length.cm) 1.00 1.00 2.301 0.1309
## s(scar.BM) 1.00 1.00 0.011 0.9172
## s(PC1) 2.56 2.56 2.936 0.0743 .
## s(PC2) 1.00 1.00 1.242 0.2665
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## R-sq.(adj) = 0.151
## Scale est. = 32.194 n = 194
plot(gamm$gam,pages=1)